/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.sub;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.bridge.JSkyBridge;
import ru.jSkyRoom.interfaces.sub.JSkyQuestLogEntry;
import ru.jSkyRoom.interfaces.sub.JSkyQuestStage;
import skyproc.QUST.QuestLogEntry;
import skyproc.QUST.QuestStage;
import skyproc.QUST.QuestStageFlags;

/**
 *
 * @author Rakev
 */
public class QuestStageBridge extends JSkyBridge<QuestStage> implements JSkyQuestStage {

    public QuestStageBridge(QuestStage rawObject) {
        super(rawObject);
    }

    @Override
    public int getJournalIndex() {
        return getRawObject().getJournalIndex();
    }

    @Override
    public void setJournalIndex(int value) {
        getRawObject().setJournalIndex(value);
    }

    @Override
    public boolean getFlag(QuestStageFlags flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void setFlag(QuestStageFlags flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unsetFlag(QuestStageFlags flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public Collection<JSkyQuestLogEntry> getLogEntries() {
        Collection<QuestLogEntry> rawEntrys = getRawObject().getLogEntries();
        Collection<? extends QuestLogEntryBridge> entrys = getBridgeFactory().createBridges(rawEntrys, QuestLogEntryBridge.class);
        return Collections.<JSkyQuestLogEntry>unmodifiableCollection(entrys);
    }

    @Override
    public void addLogEntry(JSkyQuestLogEntry entry) {
        if (entry instanceof QuestLogEntryBridge) {
            QuestLogEntry questLogEntry = ((QuestLogEntryBridge) entry).getRawObject();
            getRawObject().addLogEntry(questLogEntry);
        } else {
            throw new IllegalArgumentException("Supported only QuestLogEntryBridge");
        }
    }

    @Override
    public void removeLogEntry(JSkyQuestLogEntry entry) {
        if (entry instanceof QuestLogEntryBridge) {
            QuestLogEntry questLogEntry = ((QuestLogEntryBridge) entry).getRawObject();
            getRawObject().getLogEntries().remove(questLogEntry);
        } else {
            throw new IllegalArgumentException("Supported only QuestLogEntryBridge");
        }
    }

}
